//根据QueryString参数名称获取值

function getQueryStringByName(name){

     var result = location.search.match(new RegExp("[\?\&]" + name+ "=([^\&]+)","i"));

     if(result == null || result.length < 1){

         return "";

     }

     return result[1];

}
function getCookie(name)
{
var arr,reg=new RegExp("(^| )"+name+"=([^;]*)(;|$)");
if(arr=document.cookie.match(reg))
return unescape(arr[2]);
else
return null;
}
function setCookie(name,value)
{
var Days = 30;
var exp = new Date();
exp.setTime(exp.getTime() + Days*24*60*60*1000);
document.cookie = name + "="+ escape (value) + ";expires=" + exp.toGMTString();
}
function delCookie(name) 
{ 
    var exp = new Date(); 
    exp.setTime(exp.getTime() - 1); 
    var cval=getCookie(name); 
    if(cval!=null) 
        document.cookie= name + "="+cval+";expires="+exp.toGMTString(); 
} 
function checkUser(str){
    var re = /^\d+$/;
    if(re.test(str)){
        return false;
    }else{
        return true;
    }          
}
function checkSpecial(str){
    var re =/^[0-9a-zA-Z\u4e00-\u9fa5]+$/;
    if(re.test(str)){
        return true;
    }else{
        return false;
    }          
}
function checkEmail(str){
    var re = /^(\w-*\.*)+@(\w-?)+(\.\w{2,})+$/
    if(re.test(str)){
        return true;
    }else{
        return false;
    }
}
function checkMobile(str) {
    var re = /^1\d{10}$/
    if(re.test(str)){
        return true;
    }else{
        return false;
    }
}
module.exports = {
	url:{
		params:getQueryStringByName,
		getCookie:getCookie,
		setCookie:setCookie,
		delCookie:delCookie
	},
	checkMobile:checkMobile,
    checkUser:checkUser,
    checkSpecial:checkSpecial
}